let {Global} = require('Global')
var {
    CasinoType
} = require("CasinoProtocol")

const MIN_BET_COUNT = 10

cc.Class({
    extends: cc.Component,
    properties: {
        min: cc.Label,

        minBetCount: MIN_BET_COUNT,
        span: MIN_BET_COUNT,
        maxBet: MIN_BET_COUNT,
    },

    onLoad() {
        this.min.string = '' + this.minBetCount
        window.sock.node.on("11-1", (e) => {
            window.roomInfo = e.detail;
            window.sock.join({ roomId: e.detail.roomVo.roomId });
        })
    },

    start() {
        this.maxBet = this.minBetCount * 20
    },

    increaseMinBet() {
        // if (!Global.gameInstance.checkMoney({ betBaseMoney: this.minBetCount + this.span })) return
        this.minBetCount += this.span
        this.min.string = this.minBetCount.toString()
    },

    decreaseMinBet() {
        this.minBetCount -= this.span
        if (this.minBetCount < MIN_BET_COUNT) { this.minBetCount = MIN_BET_COUNT }
        this.min.string = this.minBetCount.toString()
    },

    close() {
        this.node.active = false
        // window.sock.join({ roomId: window.user.roomId })
        //window.sock.login({type: 1, uid: 1000})
        // Global.gameInstance.cancelConfiged()
    },

    /**
     *  gameType: number;
        minJoinBets: number;
        minBets: number;
        maxBets: number;
     */
    confirm() {
        this.node.active = false
        window.sock.createGame({ gameType: CasinoType.CasinoType_TexasPoker, minJoinBets: this.minBetCount, minBets: this.minBetCount, maxBets: this.maxBet, roomId: window.user.roomId });
    },
})